package com.example.test.advice.第六章_枚举和注解.建议89_枚举项的数量限制在64个以内;

import java.time.Duration;
import java.time.Instant;
import java.util.EnumSet;

public class Client {

    public static void main(String[] args) {
        //包含所有枚举项的EnumSet
        EnumSet<Const> cs = EnumSet.allOf(Const.class);
        EnumSet<LargeConst> lcs = EnumSet.allOf(LargeConst.class);
        System.out.println("Const枚举项数量:"+cs.size());
        System.out.println("LargeConst枚举项数量:"+lcs.size());
        //输出两个EnumSet的class
        System.out.println(cs.getClass());
        System.out.println(lcs.getClass());
        System.out.println("======================");
        Instant first = Instant.now();
        System.out.println("cs:"+cs.contains(Const.A));
        Instant second = Instant.now();
        System.out.println("cs:耗时："+(Duration.between(first,second).toMillis())+"ms");
        System.out.println("lcs:"+lcs.contains(Const.A));
        System.out.println("lcs:耗时："+(Duration.between(second,Instant.now()).toMillis())+"ms");


    }
}
